package com.cskaoyan.controller.wx;

import com.cskaoyan.model.admin.vo.BaseData;
import com.cskaoyan.model.admin.vo.BaseRespVo;
import com.cskaoyan.model.vx.vo.GoodsCategoryByChenVO;
import com.cskaoyan.model.vx.vo.GoodsDetailByChenVO;
import com.cskaoyan.service.wx.WxGoodsByChenService;
import com.cskaoyan.service.wx.WxUserIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @Author: ChenZhuqi
 * @Date: 2021/12/2 20:35
 * @Description: 商品模块的goods相关的接口
 */
@RestController
public class WxGoodsByChenController {
    @Autowired
    WxGoodsByChenService wxGoodsByChenService;

    //goods/count
    @RequestMapping("wx/goods/count")
    public BaseRespVo goodsCount() {

        int data = wxGoodsByChenService.goodsCount();
        return BaseRespVo.ok(data);
    }

    @RequestMapping("wx/goods/category")
    public BaseRespVo goodsCategory(Integer id) {

        GoodsCategoryByChenVO data = wxGoodsByChenService.goodsCategory(id);

        return BaseRespVo.ok(data);
    }

    @RequestMapping("wx/goods/detail")
    public BaseRespVo goodsDetail(Integer id, HttpSession session) {
        Integer userId = (Integer) session.getAttribute("wxUserId");
        GoodsDetailByChenVO data = wxGoodsByChenService.goodsDetail(id,userId);
        return BaseRespVo.ok(data);
    }

    @RequestMapping("wx/goods/related")
    public BaseRespVo goodsRelated(Integer id) {
        BaseData data =wxGoodsByChenService.goodsRelated(id);
        return BaseRespVo.ok(data);
    }
}
